<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
		<meta charset="utf-8" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <ul class="forminfo" style="margin-top: 20px;">
    	<li><label>所属企业</label>${enterpriseUser.name }
		<input name="UserAccount" type="hidden" class="dfinput" maxlength="10" value="${enterpriseUser.userAccount }"></li>
    	<li><label>教师姓名</label><input name="UserName" type="text" class="dfinput" maxlength="4" value="${enterpriseUser.userName }"></li>
    	<li><label>登录密码</label><input name="UserPassword" type="password" class="dfinput" maxlength="18" value="${enterpriseUser.userPassword }"></li>
    	<li><label>性别</label><select class="forminfo_select" name="UserSex" id="UserSex">
								     	<option value="男">男</option>
								     	<option value="女">女</option>
								</select>     	
		</li>
    	<li><label>所属部门</label><input name="UserDepartment" type="text" class="dfinput" maxlength="10"value="${enterpriseUser.userDepartment }" ></li>
    	<li><label>所属职位</label><input name="UserJobTitle" type="text" class="dfinput" maxlength="10" value="${enterpriseUser.userJobTitle }"></li>
    	 <li><label>联系电话</label><input name="UserPhone" type="text" class="dfinput" id="UserPhone" onclick="phoneOnblur()" maxlength="15" value="${enterpriseUser.userPhone }"></li>
    	 <li><label>电子邮件</label><input name="UserEmail" type="text" class="dfinput" id="UserEmail" onclick="emailOnblur()" maxlength="20" value="${enterpriseUser.userEmail }"></li>
	<li><label>&nbsp;</label><input name="" type="button" onclick="submitForm();" class="btn" value="确认保存"/></li>
    </ul>
    


</body>
    <script src="js/jquery-1.7.2.js"></script>
    <script type="text/javascript" src="js/jquery.tips.js"></script>
    <script src="layer/layer.js"></script>
   <script type="text/javascript">
   function phoneOnblur(){
	 	var inp = document.getElementById("UserPhone");
		var reg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
		var result = reg.test(inp.value);
		if (!result) {
			showTips($("input[name='UserPhone']"), '手机号格式不对，请重新输入!！');
			return false;
		}
	}
   function emailOnblur(){
		var inp = document.getElementById("UserEmail");
		var reg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
		var result = reg.test(inp.value);
		if (!result) {
			showTips($("input[name='UserEmail']"), '邮箱格式不对，请重新输入!');
			return false;
		}
	}
   function submitForm() {
		if ($("input[name='UserAccount']").val() == "") {
			showTips($("input[name='UserAccount']"), '请填写用户账号!');
			return false;
		}
		if ($("input[name='UserName']").val() =="") {
			showTips($("input[name='UserName']"), '请填写教师姓名!');
			return false;
		}
		if ($("input[name='UserPassword']").val() =="") {
			showTips($("input[name='UserPassword']"), '请填写登录密码!');
			return false;
		}
		if ($("input[name='UserDepartment']").val() =="") {
			showTips($("input[name='UserDepartment']"), '请填写所属部门!');
			return false;
		}
		if ($("input[name='UserJobTitle']").val() == "") {
			showTips($("input[name='UserJobTitle']"), '请填写所属职位!');
			return false;
			}
		if ($("input[name='UserPhone']").val() == "") {
			showTips($("input[name='UserPhone']"), '请填写联系电话!');
			return false;
			}
		if ($("input[name='UserJobTitle']").val() == "") {
			showTips($("input[name='UserEmail']"), '请填写电子邮件!');
			return false;
			}
		var reg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
		var result = reg.test($("input[name='UserPhone']").val());
		if (!result) {
			showTips($("input[name='UserPhone']"), '手机号格式不对，请重新输入!！');
			return false;
		}
		var reg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
		var result = reg.test($("input[name='UserEmail']").val());
		if (!result) {
			showTips($("input[name='UserEmail']"), '邮箱格式不对，请重新输入!');
			return false;
		}
		 
			var UserSex = document.getElementById('UserSex');
			var index1 = UserSex.selectedIndex;
			var val1 = UserSex.options[index1].value;
							$.ajax({
								type : "POST",
								url : "enterpriseuser/enterpriseuser_update.do",
								data : {
									UserAccount : $("input[name='UserAccount']").val(),
									UserName : $("input[name='UserName']").val(),
									UserPassword : $("input[name='UserPassword']").val(),
									UserSex : val1,
									UserDepartment : $("input[name='UserDepartment']").val(),
									UserJobTitle : $("input[name='UserJobTitle']").val(),
									UserPhone : $("input[name='UserPhone']").val(),
									UserEmail : $("input[name='UserEmail']").val()
								},
								async : true,
								dataType : "json",
								success : function(data) {
									if ("success" == data.result) {
										parent.close();
									} else {
										layer.alert('修改失败!', {
											skin : 'layer-ext-moon'
										});
									}
								}
				});
			
		}
   function showTips(obj, tips) {
		obj.tips({
			side : 3,
			msg : tips,
			bg : '#e69138',
			time : 2
		});
	}
	</script>

</html>
